#include <cellcsp.h>
#include <string>
#include <stdio.h>
#include <stdlib.h>
#include <csp_debug.h>
#include "../../shared/pi.h"
#include "StopWatch.h"


int main(){

	char *pi_master = "sor_worker_process";
	char *pi_slave  = "sor_init_process";

	char *pi_slave_path = "./tasks/pi_slave";
	char *pi_master_path = "./tasks/pi_master";


	CSPConfig conf;

	conf.add_csp_program(pi_master_path, pi_master);
	conf.add_csp_program(pi_slave_path, pi_slave);

	StopWatch sp;
	char sp_buf[256];

	CellCSP_start(conf);
	Parallel par( new CSPProcess(pi_master), NULL);
	for(int i=0; i < N; i++){
		par.Add(new CSPProcess(pi_slave));
	}

	sp.start();
	par.Run();
	sp.stop();

	sp.timeString(sp_buf);
	printf("PI timer: %s\n", sp_buf);

	CellCSP_end();

	return 0;
}
